home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / tcclib.exe / TCCLIB.DOC < prev    next >
Encoding:
Text File  |  1990-02-15  |  46.3 KB  |  1,227 lines

  1. -------------------------------------------------------------------------
  2. Accept
  3. -------------------------------------------------------------------------
  4. void Accept( int x, int y, char *Prompt, char *Buffer, int Length );
  5.  
  6. Parameters:
  7.     x,y     column, row where the prompt will be printed
  8.     Prompt  the prompt
  9.     Buffer  the address of the buffer where the response is stored
  10.     Length  the maximum allowed length of the response
  11.  
  12. -------------------------------------------------------------------------
  13. AllBlanks
  14. -------------------------------------------------------------------------
  15. int AllBlanks( register char *cp );
  16.  
  17. Returns 1 if the string is null or all spaces.  If the string
  18. contains any non-space characters, it returns 0.
  19.  
  20. -------------------------------------------------------------------------
  21. AtSay
  22. -------------------------------------------------------------------------
  23. void AtSay( int col, int row, register char *string );
  24.  
  25. Writes the string at the given position on the screen, using the
  26. global variable "attrib" for the screen attribute.
  27.  
  28. -------------------------------------------------------------------------
  29. AtSayA
  30. -------------------------------------------------------------------------
  31. void AtSayA( int col, int row, unsigned char attrib, register char *cp );
  32.  
  33. Writes the string at the given position on the screen, using the
  34. paramter "attrib" for the screen attribute.
  35.  
  36. -------------------------------------------------------------------------
  37. AtSayF
  38. -------------------------------------------------------------------------
  39. void AtSayF( int col, int row, char *fmt, ... );
  40.  
  41. Writes the string at the given position on the screen, using the
  42. global variable "attrib" for the screen attribute.  This function
  43. allows the "printf" convention of multiple parameters.
  44.  
  45. Example: AtSayF( 5, 10, "%d %s %d", 15, "Hello World", 73 )
  46.  
  47. -------------------------------------------------------------------------
  48. AtSayFA
  49. -------------------------------------------------------------------------
  50. void AtSayFA( int col, int row, unsigned char attrib, char *fmt, ... );
  51.  
  52. Writes the string at the given position on the screen, using the
  53. paramter "attrib" for the screen attribute.  This function
  54. allows the "printf" convention of multiple parameters.
  55.  
  56. -------------------------------------------------------------------------
  57. Beep
  58. -------------------------------------------------------------------------
  59. void Beep();
  60.  
  61. Beep sounds the seaker.
  62.  
  63. -------------------------------------------------------------------------
  64. Bit
  65. -------------------------------------------------------------------------
  66. unsigned Bit( int x );
  67.  
  68. Returns the value of the xth bit.  X is zero-relative.
  69. Example: Bit(0) = 1, Bit(7) = 256
  70.  
  71. -------------------------------------------------------------------------
  72. BlockErase
  73. -------------------------------------------------------------------------
  74. void BlockErase( int x, int y, int xx, int yy );
  75.  
  76. Erases the block (window) on the screen with the top left corner
  77. denoted by x,y and the bottom right corner denoted by xx,yy.  The
  78. global variable "attrib" is used to determine what attribute will
  79. be used for the area that is erased.
  80.  
  81. -------------------------------------------------------------------------
  82. BoldText
  83. -------------------------------------------------------------------------
  84. void BoldText( void );
  85.  
  86. Changes the text attribute to the global variable A_REVERSE.
  87.  
  88. -------------------------------------------------------------------------
  89. CapsLock
  90. -------------------------------------------------------------------------
  91. void CapsLock( int flag );
  92.  
  93. If "flag" is non-zero, the caps lock will be turned on.  If "flag"
  94. is zero, the caps lock will be turned off.
  95.  
  96. -------------------------------------------------------------------------
  97. Center
  98. -------------------------------------------------------------------------
  99. void Center( int y, char *s );
  100.  
  101. Centers the string "s" on the row "y", using the global variable
  102. "attrib" for screen attributes.
  103.  
  104. -------------------------------------------------------------------------
  105. CenterA
  106. -------------------------------------------------------------------------
  107. void CenterA( int y, unsigned char attrib, char *s );
  108.  
  109. Centers the string "s" on the row "y", using the parameter
  110. "attrib" for screen attributes.
  111.  
  112. -------------------------------------------------------------------------
  113. CenterF
  114. -------------------------------------------------------------------------
  115. void CenterF( int y, char *fmt, ... );
  116.  
  117. Centers the given string on the row "y", using the parameter
  118. "attrib" for screen attributes.  Allows multiple parameters like
  119. "printf".
  120.  
  121. Example: CenterF( 10, "%s %s %s", "This", "is", "centered" );
  122.  
  123. -------------------------------------------------------------------------
  124. CenterFA
  125. -------------------------------------------------------------------------
  126. void CenterFA( int y, unsigned char attrib, char *fmt, ... );
  127.  
  128. Centers the given string on the row "y", using the parameter
  129. "attrib" for screen attributes.  Allows multiple parameters like
  130. "printf".
  131.  
  132. -------------------------------------------------------------------------
  133. ChangeBlock
  134. -------------------------------------------------------------------------
  135. void ChangeBlock( int x, int y, int xx, int yy, char attrib );
  136.  
  137. ChangeBlock changes the attributes of a block on the screen.  The
  138. top left of the block is given as x,y and the bottom right is given
  139. as xx,yy.  The screen attributes for the block are changed to the
  140. paramter "attrib".
  141.  
  142. -------------------------------------------------------------------------
  143. CheckPrn
  144. -------------------------------------------------------------------------
  145. int CheckPrn( void );
  146.  
  147. Returns a 1 if the printer is attatched and ready to print.  Returns
  148. 0 if the printer is not attached, off-line, out of paper, etc.
  149.  
  150. -------------------------------------------------------------------------
  151. ClearBeg
  152. -------------------------------------------------------------------------
  153. char *ClearBeg( register char *cp );
  154.  
  155. Returns the address of the first non-space character in the string.
  156.  
  157. -------------------------------------------------------------------------
  158. ClearBuf
  159. -------------------------------------------------------------------------
  160. void ClearBuf( void );
  161.  
  162. Clears the keyboard buffer.
  163.  
  164. -------------------------------------------------------------------------
  165. ClearCRLF
  166. -------------------------------------------------------------------------
  167. char *ClearCRLF( register char *cp );
  168.  
  169. Deletes all control characters from the end of a string.
  170. Used primarily to delete Carraige Returns and Line Feeds.
  171.  
  172. -------------------------------------------------------------------------
  173. ClearEnd
  174. -------------------------------------------------------------------------
  175. char *ClearEnd( register char *cp );
  176.  
  177. Deletes all spaces that appear at the end of a string.
  178.  
  179. -------------------------------------------------------------------------
  180. CopyFile
  181. -------------------------------------------------------------------------
  182. int CopyFile( char *src, char *dest );
  183.  
  184. Copies a disk file.
  185.  
  186. Returns -1 if there was not enough memory to allocate.
  187. Returns -2 if the source file was not found or not succesfully opened.
  188. Returns -3 if the destination file was not succesfully created.
  189. Returns -4 if there was an error writing to the destination file.
  190. Returns 0 if succesful.
  191.  
  192. -------------------------------------------------------------------------
  193. CurrentPos
  194. -------------------------------------------------------------------------
  195. unsigned char far *CurrentPos( void );
  196.  
  197. This is not a replacement for gotoxy.
  198.  
  199. Returns a far character pointer to the screen memory corresponding
  200. with the current cursor position.  Useful for writing your own fast
  201. video routines.  It automatically determines whether the display is
  202. monochrome or color, and returns the appropriate pointer.
  203.  
  204. -------------------------------------------------------------------------
  205. CursorOff
  206. -------------------------------------------------------------------------
  207. void CursorOff( void );
  208.  
  209. Turns the cursor off.
  210.  
  211. -------------------------------------------------------------------------
  212. CursorOn
  213. -------------------------------------------------------------------------
  214. void CursorOn( void );
  215.  
  216. Turns the cursor on.
  217.  
  218. -------------------------------------------------------------------------
  219. DrawBox
  220. -------------------------------------------------------------------------
  221. void DrawBox( int x, int y, int xx, int yy );
  222.  
  223. Draws a double line box on the screen.
  224.  
  225. -------------------------------------------------------------------------
  226. DrawBox1
  227. -------------------------------------------------------------------------
  228. void DrawBox1( int x, int y, int xx, int yy );
  229.  
  230. Draws a single line box on the screen.
  231.  
  232. -------------------------------------------------------------------------
  233. Exists
  234. -------------------------------------------------------------------------
  235. int Exists( char *filename );
  236.  
  237. Returns 1 if the file exists, 0 if not.
  238.  
  239. -------------------------------------------------------------------------
  240. ExplodeBox
  241. -------------------------------------------------------------------------
  242. void ExplodeBox( int x, int y, int xx, int yy );
  243.  
  244. Draws a double line box on the screen, exploding out from
  245. the center.
  246.  
  247. -------------------------------------------------------------------------
  248. ExplodeBox1
  249. -------------------------------------------------------------------------
  250. void ExplodeBox1( int x, int y, int xx, int yy );
  251.  
  252. Draws a single line box on the screen, exploding out from
  253. the center.
  254.  
  255. -------------------------------------------------------------------------
  256. FileName
  257. -------------------------------------------------------------------------
  258. char *FileName( FileStruc *fp );
  259.  
  260. Returns the filename from the structure fp.  If there is no
  261. extension, the period is not included.
  262.  
  263. -------------------------------------------------------------------------
  264. FileSize
  265. -------------------------------------------------------------------------
  266. long FileSize( char *filename );
  267.  
  268. Returns the size in bytes of the given file.  This differs from 
  269. the Turbo C funtion "filelength" in that you pass a filename
  270. rather than first openingthe file and then passing the handle.
  271.  
  272. -------------------------------------------------------------------------
  273. GComm
  274. -------------------------------------------------------------------------
  275. int GComm( void );
  276.  
  277. Returns the value of the next keypress.  The values for all special
  278. keys (F1, HOME, TAB, etc.) are defined in TCCLIB.H  If you include
  279. the header file TCCLIB.H, you may use the macros F1,F2,...F10,HOME,END,
  280. PGUP,PGDN,RIGHT,LEFT,UP,DOWN,TAB,etc.
  281.  
  282. -------------------------------------------------------------------------
  283. GCommBackground
  284. -------------------------------------------------------------------------
  285. void GCommBackground( void (*funt)(void) );
  286.  
  287. Lets the user specify a function that will be performed while the
  288. computer is waiting for a keystroke.  Examples are getting the time
  289. and putting it on the screen, or keeping a counter and blanking the
  290. screen after the counter reaches a certain point.  The function 
  291. specified must be abel to execute very quickly to insure that the
  292. GComm routine will return keystrokes reliably.
  293.  
  294. Use GCommBackground( NULL ) to turn off any previously specified
  295. background routine.
  296.  
  297. -------------------------------------------------------------------------
  298. GCommCheck
  299. -------------------------------------------------------------------------
  300. int GCommCheck( int Key );
  301.  
  302. Returns 1 if the specified key has been linked to a function.
  303. Otherwise, it returns 0.
  304.  
  305. -------------------------------------------------------------------------
  306. GCommLink
  307. -------------------------------------------------------------------------
  308. void GCommLink( int Key, void (*funct)( void ) );
  309.  
  310. Links a function to a key, so that any time that key is pressed
  311. during program execution, the specified function will be executed.
  312. This requires that GComm be used for all user input.  All input
  313. routines in this library use GComm to input keystrokes.
  314.  
  315. -------------------------------------------------------------------------
  316. GCommUnlink
  317. -------------------------------------------------------------------------
  318. void GCommUnlink( int Key );
  319.  
  320. Removes any links in the GComm module for the specified key.  See
  321. also GCommLink.
  322.  
  323. -------------------------------------------------------------------------
  324. GetAllFields
  325. -------------------------------------------------------------------------
  326. void GetAllFields( FieldStruc *Field, int NUMFIELDS,
  327.                   int (*CharHandler)( int ch ),
  328.                   void (*Update)( void ) );
  329.  
  330. This function controls the input of multiple input fields on
  331. the screen until a negative value is passed back by the user
  332. function CharHandler.  The ESCape key does not automatically
  333. terminate the function, but rather is passed to CharHandler.
  334.  
  335. Parameters:
  336.     Field:     address of the array of structures
  337.     NUMFIELDS: how many structures are in the array
  338.     CharHandler: any keys not used by GetAllFields are passed to this
  339.                this allows you to handle the F1-F10 keys, etc. for
  340.                special functions of your own.
  341.                IMPORTANT: if this function returns a negative value,
  342.                GetAllFields will return to the calling funtion.
  343.     Update:    this function is called to update the screen between
  344.                the time the user finished one field and moves on to
  345.                another.  If you have calculations to perform based on
  346.                the value of certain fields and then want to show
  347.                the results, do it in this function.
  348.  
  349. Example:
  350. FieldStruc Example[] = {
  351.    10,  5, 15, F_PTR, Variable1, 1, 0,
  352.    20,  6, 15, F_PTR, Variable2, 0, 0,
  353.    30,  7, 15, F_PTR, Variable3, 1, 0,
  354.    40,  8, 15, F_PTR, Variable4, 1, 0,
  355.    50,  9, 15, F_PTR, Variable5, 1, 0,
  356.    60, 10, 15, F_PTR, Variable6, 1, 0,
  357. };
  358.  
  359. GetAllFields( &Example, 6 );
  360. /* this will get input from the user.  If the user presses any
  361.    cursor arrow key, the routine will determine which field to
  362.    goto next, then get that field next.  The second field has a
  363.    zero in the EditFlag position, which means that it will be
  364.    output, but cannot be edited or changed. */
  365.  
  366. -------------------------------------------------------------------------
  367. GetCursor
  368. -------------------------------------------------------------------------
  369. void GetCursor( int *Top, int *Bottom );
  370.  
  371. Returns the top and bottom lines of the current cursor.
  372. Be sure to pass the addresses of integers, rather than the
  373. integers themselves to this function.
  374.  
  375. Example: GetCursor( &topline, &bottomline );
  376.  
  377. -------------------------------------------------------------------------
  378. GetDate
  379. -------------------------------------------------------------------------
  380. int GetDate( unsigned StartDate );
  381.  
  382. Pops up a calendar on the screen, and allows the user to select a
  383. date from that calendar.  The user uses PgDn/PgUp to go to the next
  384. or previous month, and UP/DOWN/LEFT/RIGHT to move from day to day 
  385. or week to week.  The calendar defaults to the date specified in
  386. StartDate.
  387.  
  388. -------------------------------------------------------------------------
  389. getchf
  390. -------------------------------------------------------------------------
  391. char getchf( char *LIST, char DEFCHAR );
  392.  
  393. Accepts a character from the keyboard.  If the char is one of the
  394. characters in the string LIST, it is returned.  Otherwise, DEFCHAR
  395. is returned.
  396.  
  397. -------------------------------------------------------------------------
  398. GetDouble
  399. -------------------------------------------------------------------------
  400. double GetDouble( void );
  401.  
  402. Accepts a string and returns the value of the string as a double.
  403.  
  404. -------------------------------------------------------------------------
  405. GetField
  406. -------------------------------------------------------------------------
  407. int GetField( FieldStruc *Field );
  408.  
  409. This is a powerful input function, capable of accepting text,
  410. integer, long, boolean, date, or double fields.
  411.  
  412. Before using this function, define a structure or array of 
  413. structures of type FieldStruc.
  414.  
  415. FieldStruc is defined in TCCLIB.H as having the following elements:
  416.     int   X             column where field starts
  417.     int   Y             row where field is
  418.     int   Len           length of field
  419.     int   Type          type of field (see chart below)
  420.     char *Address       address of variable being input
  421.     int   EditFlag      1 = allow input,  0 = view only
  422.     int   NumDecimals   how many digits to the right of the decimal
  423.                         for doubles.
  424.  
  425.      Types  Value  Description
  426.     ------  -----  ----------------
  427.     F_PTR     0    String (character array)
  428.     F_INT     1    integer
  429.     F_INT0    2    integer with preceding zeros
  430.     F_CHAR    3    single character
  431.     F_LNG     4    long
  432.     F_LNG0    5    long with preceding zeros
  433.     F_DBL     6    double
  434.     F_DATE    8    date
  435.     F_BLN     9    boolean (Y or N)
  436.  
  437. Return Values:
  438.     Pressing any of the following keys will return from GetField:
  439.  
  440.     SHFT_TAB   returns the value LEFT
  441.     CTL_RIGHT  returns the value LEFT
  442.  
  443.     TAB:       returns the value RIGHT
  444.     CTL_LEFT:  returns the value RIGHT
  445.  
  446.     The following keys return their own values:
  447.         CR  LF  DOWN  UP  PGDN  PGUP  
  448.         HOME  END  F1-F10  ESC
  449.  
  450.     RIGHT and LEFT return their respective values IF they 
  451.     are the first key pressed within a field.  Otherwise, 
  452.     they move the cursor back and forth within the field.
  453.  
  454. -------------------------------------------------------------------------
  455. GetFieldA
  456. -------------------------------------------------------------------------
  457. int GetFieldA( int x, int y, int len, int type, char *address );
  458.  
  459. This function can be used to accept a single entry field, and
  460. to relieve the programmer of setting up and array for just one
  461. entry.  See GetField for a list of Types.
  462.  
  463. -------------------------------------------------------------------------
  464. GetFile
  465. -------------------------------------------------------------------------
  466. char *GetFile( int x, int y, int xx, int yy,
  467.                char *Mask,
  468.                int FileAttrib,
  469.                int ExtOn );
  470.  
  471. This function draws a box and lists inside the box all files that
  472. match the pattern given.  The user may select a file from the list,
  473. or type in a filename at the keyboard.
  474.  
  475. -------------------------------------------------------------------------
  476. GetInt
  477. -------------------------------------------------------------------------
  478. int GetInt( void );
  479.  
  480. Accepts a string and returns the value of the string as a int.
  481.  
  482. -------------------------------------------------------------------------
  483. GetLine
  484. -------------------------------------------------------------------------
  485. int GetLine( char *ptr, int size, int start );
  486.  
  487. Accepts a line of input from the user.  The line cannot exceed
  488. "size" characters.  Entry will begin at position "start".  If the 
  489. user hits ESC, the routine will return 0.  Otherwise it returns
  490. the length of the string.
  491.  
  492. -------------------------------------------------------------------------
  493. GetLong
  494. -------------------------------------------------------------------------
  495. long GetLong( void );
  496.  
  497. Accepts a string and returns the value of the string as a long.
  498.  
  499. -------------------------------------------------------------------------
  500. GetRec
  501. -------------------------------------------------------------------------
  502. int GetRec( int filehandle, void *buffer, int sizeofrec, long fileptr );
  503.  
  504. This function reads "sizeofrec" bytes from position "fileptr"
  505. from the opened file into "buffer".  It returns 0 if successfull,
  506. -1 on error.
  507.  
  508. -------------------------------------------------------------------------
  509. GetScreen
  510. -------------------------------------------------------------------------
  511. void GetScreen( char *buffer );
  512.  
  513. Stores the 4000 bytes of screen memory at the buffer.  Make sure
  514. that the buffer is 4000 or more bytes long.
  515.  
  516. -------------------------------------------------------------------------
  517. getstringnum
  518. -------------------------------------------------------------------------
  519. int getstringnum( char *menu[], int items, int x1, int y1, int x2, int y2 );
  520.  
  521. This function draws a box at the given coordinates (x1,y1,x2,y2) and
  522. displays the strings pointed to by menu.  The user selects one by
  523. cursoring up or down to it, then pressing RETURN.  The subscript
  524. of the string that was selected is returned.
  525.  
  526. -------------------------------------------------------------------------
  527. GetVidMode
  528. -------------------------------------------------------------------------
  529. int GetVidMode( void );
  530.  
  531. Returns the current video mode.
  532.  
  533. -------------------------------------------------------------------------
  534. GetYN
  535. -------------------------------------------------------------------------
  536. int GetYN( char *s );
  537.  
  538. This function draws a box in the middle of he screen and displays the
  539. string specified.  If the user pressed 'Y' then a 1 is returned.
  540. If the use presses a 'N' then a 0 is returned.
  541.  
  542. -------------------------------------------------------------------------
  543. HideCursor
  544. -------------------------------------------------------------------------
  545. void HideCursor( void );
  546.  
  547. This function hides the cursor just off the screen, rather than
  548. turning it off.  The next video output function will restore the
  549. cursor to the screen.  Exceptions to this are the AtSay functions
  550. and OutChar functions which write directly to screen memory and
  551. do not update the cursor position.
  552.  
  553. -------------------------------------------------------------------------
  554. HLin
  555. -------------------------------------------------------------------------
  556. void HLin( int x, int y, int xx, int yy );
  557.  
  558. Draws a horizontal double line on the screen.
  559.  
  560. -------------------------------------------------------------------------
  561. HLin1
  562. -------------------------------------------------------------------------
  563. void HLin1( int x, int y, int xx, int yy );
  564.  
  565. Draws a horizontal single line on the screen.
  566.  
  567. -------------------------------------------------------------------------
  568. HorzMenu
  569. -------------------------------------------------------------------------
  570. void HorzMenu( MenuPtr *Menu, int Items, int x1, int y1, int x2, int y2 );
  571.  
  572. This function creates a Lotus-like menu on the screen.  The coordinates
  573. in x1,y1 specify where the menu is to begin.  The coordinates in
  574. x2,y2 specify where the description for each choice should be displayed.
  575.  
  576. -------------------------------------------------------------------------
  577. IsAT
  578. -------------------------------------------------------------------------
  579. int IsAT( void );
  580.  
  581. Returns a 1 if the machine is an AT-class.
  582.  
  583. -------------------------------------------------------------------------
  584. IsCGA
  585. -------------------------------------------------------------------------
  586. int IsCGA( void );
  587.  
  588. Returns a 1 if the current video is to a CGA monitor.
  589.  
  590. -------------------------------------------------------------------------
  591. IsEGA
  592. -------------------------------------------------------------------------
  593. int IsEGA( void );
  594.  
  595. Returns a 1 if the current video is to a EGA monitor.
  596.  
  597. -------------------------------------------------------------------------
  598. IsMONO
  599. -------------------------------------------------------------------------
  600. int IsMONO( void );
  601.  
  602. Returns a 1 if the current video is to a monochrome monitor.
  603.  
  604. -------------------------------------------------------------------------
  605. Julian
  606. -------------------------------------------------------------------------
  607. unsigned Julian( char *DateStr );
  608.  
  609. Returns the Julian date for the specified DateStr.  The string must be
  610. in the form mm-dd-yy or mm/dd/yy.  The year can be 19yy or just yy.
  611.  
  612. -------------------------------------------------------------------------
  613. MakeBox
  614. -------------------------------------------------------------------------
  615. void MakeBox( char *s );
  616.  
  617. This function draws a box in the middle of the screen and displays
  618. the specifed text in the box.  The box is fitted to size based on the 
  619. length of the specified text.
  620.  
  621. -------------------------------------------------------------------------
  622. MaxRAM
  623. -------------------------------------------------------------------------
  624. long MaxRAM( void );
  625.  
  626. Returns the number of bytes of installed RAM.
  627.  
  628. -------------------------------------------------------------------------
  629. NormalText
  630. -------------------------------------------------------------------------
  631. void NormalText( void );
  632.  
  633. Changes the text attribute to the global variable A_NORMAL.
  634.  
  635. -------------------------------------------------------------------------
  636. NPrint
  637. -------------------------------------------------------------------------
  638. void NPrint( int num, char *cp );
  639.  
  640. Prints the first "num" characters of cp.
  641.  
  642. -------------------------------------------------------------------------
  643. NPrintA
  644. -------------------------------------------------------------------------
  645. void NPrintA( int num, int attrib, char *cp );
  646.  
  647. Prints the first "num" characters of cp, using "attrib" as the 
  648. text attribute.
  649.  
  650. -------------------------------------------------------------------------
  651. NPrintF
  652. -------------------------------------------------------------------------
  653. void NPrintF( int num, char *fmt, ... );
  654.  
  655. Prints the first "num" characters of the expanded paramter.
  656.  
  657. -------------------------------------------------------------------------
  658. NPrintFA
  659. -------------------------------------------------------------------------
  660. void NPrintFA( int num, int attrib, char *fmt, ... );
  661.  
  662. Prints the first "num" characters of the expanded paramter, 
  663. using "attrib" for the text attribute.
  664.  
  665. -------------------------------------------------------------------------
  666. NumLock
  667. -------------------------------------------------------------------------
  668. void NumLock( int flag );
  669.  
  670. If "flag" is non-zero, the num lock will be turned on.  If "flag"
  671. is zero, the num lock will be turned off.
  672.  
  673. -------------------------------------------------------------------------
  674. OutChar
  675. -------------------------------------------------------------------------
  676. void OutChar( unsigned char c );
  677.  
  678. Outputs the character at the current row and column.
  679.  
  680. -------------------------------------------------------------------------
  681. OutCharA
  682. -------------------------------------------------------------------------
  683. void OutCharA( unsigned char attrib, unsigned char c );
  684.  
  685. Outputs the character at the current row and column, using
  686. "attrib" for the text attribute.
  687.  
  688. -------------------------------------------------------------------------
  689. posneg
  690. -------------------------------------------------------------------------
  691. int posneg( int i );
  692.  
  693. If the integer specified is negative then a -1 is returned.  If it is 
  694. positive then a 1 is returned.  If it is 0 then a 0 is returned.
  695.  
  696. -------------------------------------------------------------------------
  697. PopCurpos
  698. -------------------------------------------------------------------------
  699. void PushCurpos( void );
  700.  
  701. Restores the cursor position to what it was when PushCurpos was called.
  702.  
  703. -------------------------------------------------------------------------
  704. PushCurpos
  705. -------------------------------------------------------------------------
  706. void PushCurpos( void );
  707.  
  708. Saves the current cursor position, to be reset by PopCurpos
  709.  
  710. -------------------------------------------------------------------------
  711. PopScreen
  712. -------------------------------------------------------------------------
  713. void PushScreen( void );
  714.  
  715. Restores the cursor position to what it was the last time PushScreen 
  716. was called.
  717.  
  718. -------------------------------------------------------------------------
  719. PushScreen
  720. -------------------------------------------------------------------------
  721. void PushScreen( void );
  722.  
  723. Saves the current screen into a stack.  Up to 32 screens may be saved
  724. this way.  The next call to PopScreen will pop the screen off the stack
  725. and write it to video memory.
  726.  
  727. -------------------------------------------------------------------------
  728. PutCursor
  729. -------------------------------------------------------------------------
  730. void PutCursor( int Top, int Bottom );
  731.  
  732. This is not a replacement for gotoxy.  Rather, it determines
  733. how big the cursor is.  Use this to create a block cursor, or
  734. one that is a dash rather than an underline.
  735.  
  736. -------------------------------------------------------------------------
  737. PutDate
  738. -------------------------------------------------------------------------
  739. void PutDate( int x, int y, int format );
  740.  
  741. Puts the current date on the screen at the given position.
  742.  
  743.     Format  Output
  744.     ------  ----------------
  745.        1    MM/DD/YY
  746.        2    MMM DD, YYYY
  747.        3    DD-MMM-YY
  748.        4    MMM YY
  749.  
  750. -------------------------------------------------------------------------
  751. PutField
  752. -------------------------------------------------------------------------
  753. void PutField( FieldStruc *Field );
  754.  
  755. Puts the given field on the screen.  See Getfield for a description
  756. of FieldStruc.
  757.  
  758. -------------------------------------------------------------------------
  759. PutRec
  760. -------------------------------------------------------------------------
  761. int PutRec( int filehandle, void *buffer, int sizeofrec, long fileptr );
  762.  
  763. Writes from "buffer" to the file.  Returns 0 on success, -1 on error.
  764. See also GetRec.
  765.  
  766. -------------------------------------------------------------------------
  767. PutScreen
  768. -------------------------------------------------------------------------
  769. void PutScreen( char *buffer );
  770.  
  771. Puts from memory to the screen.  Buffer must be 4000 bytes long.
  772.  
  773. -------------------------------------------------------------------------
  774. PutTime
  775. -------------------------------------------------------------------------
  776. void PutTime( int x, int y, int format );
  777.  
  778. Puts the current time on the screen at the given position.
  779.  
  780.     Format  Output
  781.     ------  ----------------
  782.        1    HH:MM:SS (24-hour)
  783.        2    HH:MM    (24-hour)
  784.        3    HH:MM:SS AM/PM
  785.        4    HH:MM    AM/PM
  786.  
  787. -------------------------------------------------------------------------
  788. RepChar
  789. -------------------------------------------------------------------------
  790. void RepChar( int num, unsigned char c );
  791.  
  792. Writes the character "c" "num" times at the given location.
  793.  
  794. -------------------------------------------------------------------------
  795. RepCharAttr
  796. -------------------------------------------------------------------------
  797. void RepCharAttr( int num, unsigned char attrib, unsigned char c );
  798.  
  799. Writes the character "c" "num" times at the given location,
  800. using "attrib" for the text attribute.
  801.  
  802. -------------------------------------------------------------------------
  803. RestoreCurPos
  804. -------------------------------------------------------------------------
  805. void RestoreCurPos( unsigned char far *scptr );
  806.  
  807. This funtion is called at the end of the Say family of functions
  808. to set the cursor position after printing the string.  It can be 
  809. used to set the cursor position to an absolute screen memory 
  810. position.
  811.  
  812. -------------------------------------------------------------------------
  813. RevJul
  814. -------------------------------------------------------------------------
  815. char *RevJul( unsigned date );
  816.  
  817. Returns the given date as a string in the form MM-DD-YY.
  818.  
  819. -------------------------------------------------------------------------
  820. ReverseText
  821. -------------------------------------------------------------------------
  822. void ReverseText( void );
  823.  
  824. Changes the text attribute to the global variable A_REVERSE.
  825.  
  826. -------------------------------------------------------------------------
  827. Say
  828. -------------------------------------------------------------------------
  829. void Say( register char *cp );
  830.  
  831. Same as puts or cputs, only quicker.
  832.  
  833. -------------------------------------------------------------------------
  834. SayA
  835. -------------------------------------------------------------------------
  836. void SayA( unsigned char attrib, register char *cp );
  837.  
  838. Same as Say, except that "attrib" is used for text attributes.
  839.  
  840. -------------------------------------------------------------------------
  841. SayF
  842. -------------------------------------------------------------------------
  843. void SayF( char *fmt, ... );
  844.  
  845. Same as printf or cprintf, only quicker.
  846.  
  847. -------------------------------------------------------------------------
  848. SayFA
  849. -------------------------------------------------------------------------
  850. void SayFA( char attrib, char *fmt, ... );
  851.  
  852. Same as printf or cprintf.  "attrib" is used for text attributes.
  853.  
  854. -------------------------------------------------------------------------
  855. ScanDir
  856. -------------------------------------------------------------------------
  857. FileStruc *ScanDir( char *Mask, int FileAttrib );
  858.  
  859. Searches for files matching the mask.  If no directory
  860. is included in the mask, the current  directory will be used.
  861. "FileAttrib" tells ScanDir which types of files to allow.
  862. (Hidden, System, etc.)  0xff includes files of all types, 
  863. 0x00 includes only those files which appear in a normal directory 
  864. listing from DOS. See DOS.H for file types and corresponding 
  865. attributes.
  866.  
  867. -------------------------------------------------------------------------
  868. ScanTree
  869. -------------------------------------------------------------------------
  870. void ScanTree( char *path, char *filespec,
  871.                void (*FN)(FileStruc *f, char *p) );
  872.  
  873. ScanTree searches through "path" for files matching "filespec".
  874. It also searches any subdirectories found while searching "path".
  875. Once it finds a matching file, it calls the user-written function 
  876. "FN", passing pointers to the FileStruc for the file and the Path 
  877. where the file was found.
  878.  
  879. EXAMPLE:  Whereis Program to search drive C.  It will print
  880.           the path and filename of every file on drive C that
  881.           matches the command line argument that is passed to
  882.           this program.  You can easily extend this to include
  883.           size, date and time of the file; even stop after each
  884.           page full to wait for a keystroke.
  885.  
  886. #include "tcclib.h"
  887.  
  888. void PrintName( FileStruc *f, char *p )
  889. {
  890.     SayF("%s%s\n", p, FileName( f ) );  /* see FileName */
  891. /*
  892.     (Returning a -1 here will stop ScanTree dead in it's tracks.
  893.     see the Demo program for an example of this.)
  894. */
  895.     return( 0 );
  896. }
  897.  
  898. main( int argc, char *argv[] )
  899. {
  900.     ScanTree( "C:\\", argv[1], PrintName );
  901. }
  902.  
  903. -------------------------------------------------------------------------
  904. ScrAttr
  905. -------------------------------------------------------------------------
  906. int ScrAttr( void );
  907.  
  908. Returns the text attribute at the current location of the cursor.
  909.  
  910. -------------------------------------------------------------------------
  911. ScrChar
  912. -------------------------------------------------------------------------
  913. int ScrChar( void );
  914.  
  915. Returns the text character at the current location of the cursor.
  916.  
  917. -------------------------------------------------------------------------
  918. ScrollDown
  919. -------------------------------------------------------------------------
  920. void ScrollDown( int x, int y, int xx, int yy, int n );
  921.  
  922. Scrolls the given section of the screen down "n" lines.  If "n"
  923. equals 0, the section of the screen is blanked.
  924.  
  925. -------------------------------------------------------------------------
  926. ScrollLock
  927. -------------------------------------------------------------------------
  928. void ScrollLock( int flag );
  929.  
  930. If "flag" is non-zero, the scroll lock will be turned on.  If "flag"
  931. is zero, the scroll lock will be turned off.
  932.  
  933. -------------------------------------------------------------------------
  934. ScrollMessage
  935. -------------------------------------------------------------------------
  936. void ScrollMessage( char *msg );
  937.  
  938. This routine draws a box in the middle of the screen and scrolls the 
  939. given accross the screen from the right until it is centered.  At the
  940. same time, it scrolls the prompt "Press any key ..." over from the
  941. left until it is also centered.  It then waits until a key is pressed.
  942.  
  943. -------------------------------------------------------------------------
  944. ScrollUp
  945. -------------------------------------------------------------------------
  946. void ScrollUp( int x, int y, int xx, int yy, int n );
  947.  
  948. Scrolls the given section of the screen up "n" lines.  If "n"
  949. equals 0, the section of the screen is blanked.
  950.  
  951. -------------------------------------------------------------------------
  952. ScrPtr
  953. -------------------------------------------------------------------------
  954. unsigned char far *ScrPtr( int col, int row );
  955.  
  956. Returns a pointer into screen memory for the given row and column.
  957.  
  958. -------------------------------------------------------------------------
  959. SetAttrib
  960. -------------------------------------------------------------------------
  961. void SetAttrib( char attribute  );
  962.  
  963. Set the text attribute to "attribute"
  964.  
  965. -------------------------------------------------------------------------
  966. SetVidMode
  967. -------------------------------------------------------------------------
  968. void SetVidMode( int mode );
  969.  
  970. Set the video mode to "mode"
  971.  
  972. -------------------------------------------------------------------------
  973. strdel
  974. -------------------------------------------------------------------------
  975. char *strdel( char *STRING, int START, int NUM );
  976.  
  977. Deletes NUM characters from STRING starting with START.
  978.  
  979. -------------------------------------------------------------------------
  980. strins
  981. -------------------------------------------------------------------------
  982. char *strins( char *STRING, int START, char *INSTR );
  983.  
  984. Inserts INSTR into STRING starting at START.
  985.  
  986. -------------------------------------------------------------------------
  987. stristr
  988. -------------------------------------------------------------------------
  989. char *stristr( char *STRING1, char *STRING2 );
  990.  
  991. Searches for occurences of STRING1 in STRING2, ignoring case, and 
  992. returns the address of STRING1 within STRING2 if it exists, or NULL
  993. if is is not found.
  994.  
  995. -------------------------------------------------------------------------
  996. StrLeft
  997. -------------------------------------------------------------------------
  998. void StrLeft( char *dest, char *src, int num );
  999.  
  1000. Copies the leftmost "num" characters from "src" to "dest".
  1001.  
  1002. -------------------------------------------------------------------------
  1003. strresize
  1004. -------------------------------------------------------------------------
  1005. char *strresize( char *STRING, int NEWSIZE );
  1006.  
  1007. Makes STRING1 to be NEWSIZE bytes long, either by truncating or adding
  1008. spaces.
  1009.  
  1010. -------------------------------------------------------------------------
  1011. StrRight
  1012. -------------------------------------------------------------------------
  1013. void StrRight( char *dest, char *src, int num );
  1014.  
  1015. Copies the rightmost "num" characters from "src" to "dest".
  1016.  
  1017. -------------------------------------------------------------------------
  1018. StrRpl
  1019. -------------------------------------------------------------------------
  1020. void StrRpl( char *string, int startpos, int num, char *replacestring );
  1021.  
  1022. Replaces a portion of "string" with "replacestring".  It begins
  1023. replacing at position "startpos", and replaces "num" characters.
  1024.  
  1025. -------------------------------------------------------------------------
  1026. TimeElapsed
  1027. -------------------------------------------------------------------------
  1028. double TimeElapsed( void );
  1029.  
  1030. Returns how many seconds have passed since "TimerStart" was
  1031. last called.
  1032.  
  1033. -------------------------------------------------------------------------
  1034. TimerStart
  1035. -------------------------------------------------------------------------
  1036. void TimerStart( void );
  1037.  
  1038. Begins the timer.
  1039.  
  1040. -------------------------------------------------------------------------
  1041. TodaysDate
  1042. -------------------------------------------------------------------------
  1043. unsigned TodaysDate( void );
  1044.  
  1045. Returns the Julian of the current date.
  1046.  
  1047. -------------------------------------------------------------------------
  1048. VertMenu
  1049. -------------------------------------------------------------------------
  1050. void VertMenu( MenuRec MP[], int Items, int x, int y, int xx, int yy );
  1051.  
  1052. Creates a vertical menu on the screen at the given coordinates.  
  1053. Similar to HorzMenu, except that items are listed down rather than 
  1054. across.  When an item is selected, the function associated with that 
  1055. item in the MenuRec is executed.
  1056.  
  1057.  
  1058. -------------------------------------------------------------------------
  1059. VLin
  1060. -------------------------------------------------------------------------
  1061. void VLin( int x, int y, int xx, int yy );
  1062.  
  1063. Draws a vertical double line on the screen.
  1064.  
  1065. -------------------------------------------------------------------------
  1066. VLin1
  1067. -------------------------------------------------------------------------
  1068. void VLin1( int x, int y, int xx, int yy );
  1069.  
  1070. Draws a single vertical line on the screen.
  1071.  
  1072. -------------------------------------------------------------------------
  1073. WeekDay
  1074. -------------------------------------------------------------------------
  1075. int WeekDay( void );
  1076.  
  1077. Returns an integer representing the day of the week.  0 = Sunday,
  1078. 1=Monday, etc.
  1079.  
  1080. -------------------------------------------------------------------------
  1081. WindowLister
  1082. -------------------------------------------------------------------------
  1083. int WindowLister( int x, int y, int xx, int yy,
  1084.                          int CharToQuitOn,
  1085.                          int *NumItems,
  1086.                          int NumToStartWith,
  1087.                          int(*CharHandler)(int ch, int ndx),
  1088.                          void(*ScreenClearer)( void ),
  1089.                          void(*DisplayLineFunction)(int Index) );
  1090.  
  1091. This function may be difficult to understand, but will be
  1092. well worth the time.  It lets you browse through an array of 
  1093. structures or simple data types, using the PgDn/PgUp and up/down
  1094. arrows.  You must first create three special functions.  This function
  1095. should save you lots of programming time, once you learn how to
  1096. use it.  It returns the index of the item it was highlighting when the
  1097. "CharToQuitOn" key was pressed.
  1098.  
  1099. Parameters:
  1100.     x, y, xx, yy:        the section of the screen for WindowLister
  1101.                          to use.
  1102.  
  1103.     CharToQuitOn:        this will usually be ESC.
  1104.  
  1105.     NumItems:            this tells WindowLister how many records are 
  1106.                          in the array.  It is passed as the address
  1107.                          of an integer so that if during operation
  1108.                          you delete or add records, you just change 
  1109.                          the value of this integer, and WindowLister
  1110.                          will adjust accordingly.
  1111.  
  1112.     NumToStartWith:      which record to begin with.  Usually 0.
  1113.  
  1114.     CharHandler:         whenever WindowLister receives a key it
  1115.                          doesn't process, it will pass the inkey
  1116.                          to your CharHandler function.  Your character
  1117.                          handler function should perform whatever is
  1118.                          appropriate for the given keypress,
  1119.                          then it should return the index into
  1120.                          the array that should be highlighted next.
  1121.                          This will usually be the same "ndx" that was
  1122.                          passed to it, but you can change it and 
  1123.                          WindowLister will jump to the new index you
  1124.                          pass back to it.
  1125.  
  1126.     ScreenClearer:       This clears whatever sections of the screen
  1127.                          are filled with the records of the array.
  1128.  
  1129.     DisplayLineFunction: This function should output a single record of 
  1130.                          the array.
  1131.  
  1132. Example:
  1133. #define MAIN
  1134. #include "tcclib.h"
  1135.  
  1136. typedef struct {
  1137.     char Name[21];
  1138.     char City[21];
  1139.     char State[3];
  1140.     long ZIP;
  1141. } ExampleType;
  1142.  
  1143. ExampleType Example[100];
  1144.  
  1145. int MaxItems = 50; /* we will assume that 50 are filled with data.
  1146.                       NOTE: this number represent how many are currently 
  1147.                       in use, not the total capacity which is 100. */
  1148.  
  1149. int ElementCompare( ExampleType *a, ExampleType *b )
  1150. /* this is defined for the quicksort below */
  1151. {
  1152.     return( stricmp( a->Name, b->Name ) );
  1153. }
  1154.  
  1155. int ExampleCharacterHandler( int ch, int ndx )
  1156. /* ch   = the character WindowLister didn't recognize F1-F10, INS, DEL, 
  1157.           etc. */
  1158. /* ndx  = index into the array where the WindowLister is */
  1159. {
  1160.     switch( ch ) {
  1161.         case DEL:    /*  Delete a record */
  1162.             /* perform deletion of "ndx"th record of array Example.
  1163.                the code is not written here */
  1164.             MaxItems--;
  1165.             break;
  1166.         case INS:
  1167.             /* perform an insert here - record at position "ndx" 
  1168.                the code is not written here */
  1169.             MaxItems++;
  1170.             break;
  1171.         case F4: 
  1172.             /* sort the items in the array Example */
  1173.             qsort( &Example, MaxItems, sizeof( ExampleType ), 
  1174.                 ElementCompare );
  1175.             break;
  1176.     }
  1177.     return( ndx );
  1178. }
  1179.  
  1180. void ExampleScreenClearer( void )
  1181. /* usually this will be a BlockErase, but if you want to get fancy,
  1182.    you have the flexibilty to do just about anything you want to */
  1183. {
  1184.     BlockErase( 6, 6, 74, 19 );
  1185. }
  1186.  
  1187. void ExampleDisplayFunction( int Index )
  1188. /* All that this function needs to do is output a single record
  1189.    in the proper format.  WindowLister will position the cursor before
  1190.    calling this routine, so this should not reposition the cursor
  1191.    before printing. Also, no newline is needed at the end. */
  1192. {
  1193.     SayF("%-20s  %-20s  %-2s  %05ld", 
  1194.         Example[Index].Name,
  1195.         Example[Index].City,
  1196.         Example[Index].State,
  1197.         Example[Index].ZIP );
  1198. }
  1199.  
  1200. main()
  1201. {
  1202.     clrscr();
  1203.     DrawBox( 4, 4, 76, 21 );
  1204.     Center( 25, "Use INS, DEL;  F4=Sort" );
  1205.     WindowLister( 5, 5, 75, 20, ESC, &MaxItems, 0, 
  1206.                   ExampleCharacterHandler,
  1207.                   ExampleScreenClearer,
  1208.                   ExampleDisplayFunction );
  1209. }
  1210.  
  1211. -------------------------------------------------------------------------
  1212. XDrawBox
  1213. -------------------------------------------------------------------------
  1214. void XDrawBox( int x, int y, int xx, int yy );
  1215.  
  1216. Explodes a box onto the screen at the given coordinates.  The box
  1217. explodes out from the middle.
  1218.  
  1219. -------------------------------------------------------------------------
  1220. XDrawBox1
  1221. -------------------------------------------------------------------------
  1222. void XDrawBox1( int x, int y, int xx, int yy );
  1223.  
  1224. Explodes a single-line box onto the screen at the given coordinates.  
  1225. The box explodes out from the middle.
  1226.  
  1227.